﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace COC.Threading
{
    public class CEventQueue
    {
        private Queue<WorkEventItem> eventQueue = new Queue<WorkEventItem>();
        private ICollection<WorkEventItem> combinator = new Collection<WorkEventItem>();

        public void PushEvent(WorkEventItem e)
        {
            combinator.Clear();
            combinator.Add(e);
            PushEvent(combinator);
        }
        public void PushEvent(ICollection<WorkEventItem> collection)
        {
            int count = collection.Count;
            if (count > 0)
            {
                IEnumerator<WorkEventItem> iterator = collection.GetEnumerator();
                while (iterator.MoveNext())
                {
                    eventQueue.Enqueue(iterator.Current);
                }
            }
        }

        public WorkEventItem Dequeue()
        {
            return eventQueue.Dequeue();
        }
        public WorkEventItem Peek()
        {
            return eventQueue.Peek();
        }

        public int Count()
        {
            return eventQueue.Count;
        }

    }
}